package br.edu.univas.si.engs.view;

import java.awt.BorderLayout;
import java.awt.Frame;
import java.util.ArrayList;

import javax.swing.JDialog;

import br.edu.univas.si.engs.controller.Controller;
import br.edu.univas.si.engs.model.CarTO;


public class FrameConsultarCarroReserva extends JDialog {


	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private PanelConsultarCarroReserva panelConsultarCarrosReserva;
	private Controller controller;
	private CarTO carrostoTo;

	
	public FrameConsultarCarroReserva(String carro,String clienteNom,int idCliente,Frame object, String string, boolean b){
		super( object,string,b);
		setTitle("Consultar Carros");
		initialziee(clienteNom,idCliente);
		//setLocationRelativeTo(null); 
		setLocation(290, 130);
		//setModal(true);
		pack();
		//setSize(1000,600);
		
	}

	
	


	public  PanelConsultarCarroReserva getPanelConsultarCarReserva (final String clienteNom, final int idCliente) {
		if(panelConsultarCarrosReserva==null){
			panelConsultarCarrosReserva=new PanelConsultarCarroReserva(clienteNom,idCliente);
			
			panelConsultarCarrosReserva.setButtonListenerConsulCarroReserv(new ButtomListenerConsultarCarroReserva() {
				
				@Override
				public void limparAction() {
					//panelConsultarCarrosReserva.setText(null);
					panelConsultarCarrosReserva.limparTable();
						
					
				}
				
				@Override
				public void consultarCarrosAcition() {
					
					CarTO carros= new CarTO();
					ArrayList<CarTO> listCarros = new ArrayList<CarTO>();
					listCarros=getController().consultaCarroPorModelo(getPanelConsultarCarReserva(clienteNom, idCliente).getcontactCarrosTo().getModelo());
					//panelConsultarCarrosReserva.limparTable();
					getPanelConsultarCarReserva(clienteNom, idCliente).addContactCarros(listCarros);
			
				}
			});
				
		
				
		
				
			
		}
		return panelConsultarCarrosReserva;
	}









	public Controller getController() {
		if(controller==null){
			
			controller= new Controller(null, null,  null,  null, null);
		}
		return controller;
	}









	public CarTO getCarrostoTo() {
		if(carrostoTo==null){
			carrostoTo = new CarTO();
		}
		return carrostoTo;
	}






	
	
	
	
	
	
	private void initialziee( String clienteNom, int idCliente) {
	add(getPanelConsultarCarReserva(clienteNom, idCliente),BorderLayout.SOUTH);
	//add(getButtonPanelConsultarCliente(),BorderLayout.SOUTH);
	
		
	}

}

